#!/usr/bin/python
#coding=utf-8

import sys;
f = lambda : map(int, raw_input().split());
n, k = f();

num = [f() for i in range(n)];

for x in num:
		x[0] = -x[0];

num.sort();

print num.count(num[k-1]);
